<?php
declare (strict_types=1);

namespace app\validate;

use think\Validate;

class Inventory extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'title' => 'require',
        'record_user_id' => 'number|require',
        'user_id' => 'number|require',
        'type' => 'number|require',
        'goods_list' => 'require',
        'warehouse_id' => 'number|require'
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'title.require' => '标题是必填字段',
        'record_user_id.require' => '记录人是必填字段',
        'record_user_id.number' => '记录人格式不正确',
        'user_id.require' => '领用人是必填字段',
        'user_id.number' => '领用人格式不正确',
        'warehouse_id.require' => '仓库是必填字段',
        'warehouse_id.number' => '仓库格式不正确',
        'goods_list.require' => '物品列表是必填字段',
        'type.require' => '类型是必填字段',
        'type.number' => '类型格式不正确',
    ];

    protected $scene = [
        'putMaterial' => ['title', 'warehouse_id', 'record_user_id', 'goods_list', 'type'],
        'outMaterial' => ['title', 'user_id', 'record_user_id', 'goods_list', 'type']
    ];
}
